<template>
  <views class="user_managen">
    <viewTitle :title="'签约导入'" :border="false"></viewTitle>
    <el-button type="primary" class="review_btn" @click="fastCheck">一键审核</el-button>
    <!-- 展示列表 -->
    <div class="table_list">
      <el-table
        border
        :data="tableData"
        style="width: 100%;max-width:none;"
        :header-cell-style="getRowClass"
        :select-on-indeterminate="true"
        :fit="true"
        :lazy="true"
        @row-click="clickRow"
        max-height="450"
      >
        <el-table-column type="index" label="序号" width="100"></el-table-column>
        <el-table-column prop="name" label="用户名称" width="200"></el-table-column>
        <el-table-column prop="cer_code" label="身份证号" width="120"></el-table-column>
        <el-table-column prop="mobile" label="手机号码" width="120"></el-table-column>
        <el-table-column prop="bank_code" label="银行卡号" width="120"></el-table-column>
        <el-table-column prop="" label="备注" width="120"></el-table-column>

        <el-table-column
          prop="created_time"
          :formatter="(row)=>{ return  row.created_time > 0  ?  this.$moment(row.created_time*1000).format('YYYY-MM-DD HH:MM:SS'):''; }"
          label="创建时间"
          width="auto"
        ></el-table-column>
        <el-table-column label="操作" flex="right" width="200">
          <template slot-scope="scope">
            <div class="table_operation flex flexR">
              <el-button type="danger"  @click="del_user(scope)">删除</el-button>
              <el-button type="primary" @click="check_user(scope)">通过</el-button>
            </div>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div class="flex flexR paging">
      <el-pagination
        style="background:#fff; padding:10px 0"
        background
        layout="total, sizes,prev, pager, next, jumper"
        @size-change="(page_size) => {this.pagination.page_size = page_size;this.getData()}"
        @current-change="(page_size) => {this.pagination.page_start = page_size;this.getData()}"
        :page-sizes="[10, 20, 30, 50]"
        :page-size="pagination.page_size"
        :total="pagination.total_count"
        :current-page="pagination.current_page"
        :page-count="pagination.page_count"
      ></el-pagination>
    </div>
  </views>
</template>



<script>
import { mapGetters } from 'vuex';

export default {
  data() {
    return {
      //  三段综合  企业端  代理商端  服务商端,
      pagination: {
        page_start: 0, //搜索开始页码
        current_page: 0, //当前页码
        page_count: 0, //总页数
        page_size: 10, //每页数量
        total_count: 0 //总数量
      },
      tableData: [],
      pickerOptions: {
        shortcuts: [
          {
            text: "最近一周",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit("pick", [start, end]);
            }
          },
          {
            text: "最近一个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit("pick", [start, end]);
            }
          },
          {
            text: "最近三个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit("pick", [start, end]);
            }
          }
        ]
      }
    };
  },
  computed: {
  },
  mounted() {
    this.getData();
  },
  methods: {
    //    修改第一行样式
    getRowClass({ row, column, rowIndex, columnIndex }) {
      if (rowIndex === 0) {
        return "background: #FAFAFA ";
      } else {
        return "";
      }
    },
    //     点击单行
    clickRow(row, column, event) {
      console.log(row, column, event);
    },
    //    修改是否换行
    changeStyleRow(width) {
      let _width = width - 290 - 350 - 300 - 50 - 25;
      if (_width > 300) {
        this.marginLeft = 25;
      } else {
        this.marginLeft = 0;
      }
    },
    check_user(scope) {
        this.$confirm("你确定要审核该用户么, 是否继续?", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning"
        })
            .then(() => {
                let { code, msg } = this.$api.sendSync(
                    this.$mapapi.eimportCheck,
                    {
                        enterprise_professional_import_id: scope.row.enterprise_professional_import_id
                    }
                );
                if (code != 200) {
                    this.$message.error(msg);
                    return;
                }
                this.getData();
                this.$message({
                    type: "success",
                    message: "已审核!"
                });
            })
            .catch(() => {
                this.$message({
                    type: "info",
                    message: "已取消"
                });
            });
    },
    del_user(scope) {

        this.$confirm("你确定要删除用户么, 是否继续?", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning"
        })
            .then(() => {
                let { code, msg } = this.$api.sendSync(
                    this.$mapapi.eimportDel,
                    {
                        enterprise_professional_import_id: scope.row.enterprise_professional_import_id
                    }
                );
                if (code != 200) {
                    this.$message.error(msg);
                    return;
                }
                this.getData();
                this.$message({
                    type: "success",
                    message: "已删除!"
                });
            })
            .catch(() => {
                this.$message({
                    type: "info",
                    message: "已取消"
                });
            });
    },
    getData() {
        let { code, msg, data } = this.$api.sendSync(
            this.$mapapi.eimportList,
            { pagination : this.pagination}
        );
        if (code != 200 && code != 501) {
            this.$message.error(msg);
            this.tableData = [];
            return;
        }
        this.tableData = data.list;
    },
      fastCheck(){
          this.$confirm("你确定要执行一键审核吗, 是否继续?", "提示", {
              confirmButtonText: "确定",
              cancelButtonText: "取消",
              type: "warning"
          })
              .then(() => {
                  let { code, msg } = this.$api.sendSync(
                      this.$mapapi.efastCheck,{}
                  );
                  if (code != 200 && code != 501) {
                      this.$message.error(msg);
                      return;
                  }
                  this.getData();
              })
              .catch(() => {
                  this.$message({
                      type: "info",
                      message: "已取消"
                  });
              });



      }
  },
  created() {}
};
</script>


<style lang="less" :scope="true"  src="@/style/sManagement/user_managen.less" >
</style>